home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / bombjack.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  4KB  |  191 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13.  
  14. static int background_image;
  15. static int flipscreen;
  16.  
  17.  
  18.  
  19. WRITE_HANDLER( bombjack_background_w )
  20. {
  21.     if (background_image != data)
  22.     {
  23.         memset(dirtybuffer,1,videoram_size);
  24.         background_image = data;
  25.     }
  26. }
  27.  
  28.  
  29.  
  30. WRITE_HANDLER( bombjack_flipscreen_w )
  31. {
  32.     if (flipscreen != (data & 1))
  33.     {
  34.         flipscreen = data & 1;
  35.         memset(dirtybuffer,1,videoram_size);
  36.     }
  37. }
  38.  
  39.  
  40.  
  41. /***************************************************************************
  42.  
  43.   Draw the game screen in the given osd_bitmap.
  44.   Do NOT call osd_update_display() from this function, it will be called by
  45.   the main emulation engine.
  46.  
  47. ***************************************************************************/
  48. void bombjack_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  49. {
  50.     int offs,base;
  51.  
  52.  
  53.     if (palette_recalc())
  54.         memset(dirtybuffer,1,videoram_size);
  55.  
  56.     base = 0x200 * (background_image & 0x07);
  57.  
  58.     /* for every character in the Video RAM, check if it has been modified */
  59.     /* since last time and update it accordingly. */
  60.     for (offs = videoram_size - 1;offs >= 0;offs--)
  61.     {
  62.         int sx,sy;
  63.         int tilecode,tileattribute;
  64.  
  65.  
  66.         sx = offs % 32;
  67.         sy = offs / 32;
  68.  
  69.         if (background_image & 0x10)
  70.         {
  71.             int bgoffs;
  72.  
  73.  
  74.             bgoffs = base+16*(sy/2)+sx/2;
  75.  
  76.             tilecode = memory_region(REGION_GFX4)[bgoffs],
  77.             tileattribute = memory_region(REGION_GFX4)[bgoffs + 0x100];
  78.         }
  79.         else
  80.         {
  81.             tilecode = 0xff;
  82.             tileattribute = 0;    /* avoid compiler warning */
  83.         }
  84.  
  85.         if (dirtybuffer[offs])
  86.         {
  87.             if (flipscreen)
  88.             {
  89.                 sx = 31 - sx;
  90.                 sy = 31 - sy;
  91.             }
  92.  
  93.             /* draw the background (this can be handled better) */
  94.             if (tilecode != 0xff)
  95.             {
  96.                 struct rectangle clip;
  97.                 int flipy;
  98.  
  99.  
  100.                 clip.min_x = 8*sx;
  101.                 clip.max_x = 8*sx+7;
  102.                 clip.min_y = 8*sy;
  103.                 clip.max_y = 8*sy+7;
  104.  
  105.                 flipy = tileattribute & 0x80;
  106.                 if (flipscreen) flipy = !flipy;
  107.  
  108.                 drawgfx(tmpbitmap,Machine->gfx[1],
  109.                         tilecode,
  110.                         tileattribute & 0x0f,
  111.                         flipscreen,flipy,
  112.                         16*(sx/2),16*(sy/2),
  113.                         &clip,TRANSPARENCY_NONE,0);
  114.  
  115.                 drawgfx(tmpbitmap,Machine->gfx[0],
  116.                         videoram[offs] + 16 * (colorram[offs] & 0x10),
  117.                         colorram[offs] & 0x0f,
  118.                         flipscreen,flipscreen,
  119.                         8*sx,8*sy,
  120.                         &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  121.             }
  122.             else
  123.                 drawgfx(tmpbitmap,Machine->gfx[0],
  124.                         videoram[offs] + 16 * (colorram[offs] & 0x10),
  125.                         colorram[offs] & 0x0f,
  126.                         flipscreen,flipscreen,
  127.                         8*sx,8*sy,
  128.                         &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  129.  
  130.  
  131.             dirtybuffer[offs] = 0;
  132.         }
  133.     }
  134.  
  135.  
  136.     /* copy the character mapped graphics */
  137.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  138.  
  139.  
  140.     /* Draw the sprites. */
  141.     for (offs = spriteram_size - 4;offs >= 0;offs -= 4)
  142.     {
  143.  
  144. /*
  145.  abbbbbbb cdefgggg hhhhhhhh iiiiiiii
  146.  
  147.  a        use big sprites (32x32 instead of 16x16)
  148.  bbbbbbb  sprite code
  149.  c        x flip
  150.  d        y flip (used only in death sequence?)
  151.  e        ? (set when big sprites are selected)
  152.  f        ? (set only when the bonus (B) materializes?)
  153.  gggg     color
  154.  hhhhhhhh x position
  155.  iiiiiiii y position
  156. */
  157.         int sx,sy,flipx,flipy;
  158.  
  159.  
  160.         sx = spriteram[offs+3];
  161.         if (spriteram[offs] & 0x80)
  162.             sy = 225-spriteram[offs+2];
  163.         else
  164.             sy = 241-spriteram[offs+2];
  165.         flipx = spriteram[offs+1] & 0x40;
  166.         flipy =    spriteram[offs+1] & 0x80;
  167.         if (flipscreen)
  168.         {
  169.             if (spriteram[offs+1] & 0x20)
  170.             {
  171.                 sx = 224 - sx;
  172.                 sy = 224 - sy;
  173.             }
  174.             else
  175.             {
  176.                 sx = 240 - sx;
  177.                 sy = 240 - sy;
  178.             }
  179.             flipx = !flipx;
  180.             flipy = !flipy;
  181.         }
  182.  
  183.         drawgfx(bitmap,Machine->gfx[(spriteram[offs] & 0x80) ? 3 : 2],
  184.                 spriteram[offs] & 0x7f,
  185.                 spriteram[offs+1] & 0x0f,
  186.                 flipx,flipy,
  187.                 sx,sy,
  188.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  189.     }
  190. }
  191.